package com.github.alenfive.config;

import com.github.alenfive.GlobalFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<GlobalFilter> globalFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new GlobalFilter());
        List<String> urlList = new ArrayList() {{ add("/*"); }};
        registration.setUrlPatterns(urlList);
        registration.setName("globalFilter");
        registration.setOrder(Integer.MIN_VALUE);
        return registration;
    }

}